package alogrithm.string;

public class BFSearch {
	public void search(String s,String t){
		if(s==null||t==null){
			return;
		}
		int i=0,j=0;
		while(i<s.length()&&j<t.length()){
			if(s.charAt(i)==t.charAt(j)){
				j++;
				i++;
			}else{
				i++;
				j=0;
			}
		}
		if(j==t.length()){
			System.out.println(i-j);	
		}else{
			System.out.println("-1");
		}
		
	}
	public static void main(String[] args) {
		BFSearch b=new BFSearch();
		b.search("i am search here", "search");
		
	}
}
